<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$this->load->view('logged_in/admin/header', array('current_page' => 0));

?>
	<!-- Main Wrapper -->

	<div id="main-wrapper">
		<div class="container">

			<div class="row">
				<?php $this->load->view('logged_in/admin/panel'); ?>

				<div class="8u skel-cell-important">
					<div class="8u" style="margin: 0 auto;">
						<?php
						if (isset($error))
							echo '<h3 style="color: #ffa03a">' . $error . '</h3>';
						?>
						<div class="5u" style="margin: 0 auto">
							<img style="width: 100%; border-radius: 15px"
							     src="<?php echo base_url() . 'images/avatar/' . $user['image'] ?>">
						</div>
						<form name="frmEdit" id="frmEdit" action="" method="post" enctype="multipart/form-data">
							<input type="hidden" name="id" value="<?php echo $user['userid'] ?>">

							<div class="input-group input-group-lg">
								<span class="input-group-addon">Username</span>
								<input type="text" name="username" value="<?php echo $user['username'] ?>" id="fname"
								       disabled="disabled" class="form-control">
							</div>
							<br/>

							<div class="input-group input-group-lg">
								<span class="input-group-addon">Full name</span>
								<input type="text" name="name" value="<?php echo $user['name'] ?>" id="name"
								       class="form-control">
							</div>
							<br/>

							<div class="input-group input-group-lg">
								<span class="input-group-addon">Email</span>
								<input type="text" name="email" value="<?php echo $user['email'] ?>" id="email"
								       disabled="disabled" class="form-control">
							</div>
							<br/>

							<div class="input-group input-group-lg">
								<span class="input-group-addon">Address</span>
								<input type="text" name="address" value="<?php echo $user['address'] ?>" id="address"
								       class="form-control">
							</div>
							<br/>

							<div class="input-group input-group-lg">
								<span class="input-group-addon">Activated</span>
								<select name="active" id="select_active" class="form-control">
									<option value="0" <?php echo $user['active'] == 0 ? 'selected' : '' ?> >Not Activated</option>
									<option value="1" <?php echo $user['active'] == 1 ? 'selected' : '' ?> >Activated</option>
								</select>
							</div>
							<br/>

							<div class="btn-group">
								<span class="btn btn-default btn-lg">
									<input name="gender" id="male" value="1" type="radio"
									       class="radio-inline" <?php echo $user['gender'] == 1 ? 'checked="checked' : '' ?>
									       style="margin: auto 0"/>
									<label for="male">Male</label>
								</span>
								<span class="btn btn-default btn-lg">
									<input name="gender" id="female" value="0" type="radio"
									       class="radio-inline" <?php echo $user['gender'] == 0 ? 'checked="checked' : '' ?>
									       style="margin: auto 0"/>
									<label for="female">Female</label>
								</span>
							</div>
							<br/>
							<br/>

							<div class="input-group input-group-lg">
								<input id="uploadFile" class="form-control" placeholder="Upload Avatar"
								       disabled="disabled"/>

								<div class="input-group-addon btn-lg fileUpload btn btn-primary"
								     style=" position: relative; overflow: hidden; background-color: #5cb85c; border-color: #4cae4c; color: #ffffff">
									<span>Upload</span>
									<input id="uploadBtn" name="image" type="file" class="upload"
									       style="position: absolute; top: 0; right: 0; margin: 0; padding: 0; font-size: 20px; cursor: pointer; opacity: 0; filter: alpha(opacity=0);"
									       onchange='document.getElementById("uploadFile").value = this.value;'/>
								</div>
							</div>
							<br/>

							<div class="input-group input-group-lg">
								<span class="input-group-addon">User type</span>
								<select name="level" id="select_level" class="form-control">
									<option value="1" <?php echo $user['level'] == 1 ? 'selected' : '' ?> >
										Administrator
									</option>
									<option value="2" <?php echo $user['level'] == 2 ? 'selected' : '' ?> > Member
									</option>
								</select>
							</div>
							<br/>
							<input type="submit" name="save" class="btn-lg btn-info" value="Save"/><br/>
						</form>

					</div>
				</div>
			</div>
		</div>
	</div>

	<script>
		$(document).ready(function () {
			$('#select_level').on('change', function () {
				if (this.value == 1) {    //change to admin
					$resul = window.confirm("Make this user to Admin?");
					if (!$resul)
						this.value = 2;
				}
				else {      //remove as admin
					$resul = window.confirm("Remove as Admin?");
					if (!$resul)
						this.value = 1;
				}

			})
		});
	</script>
<?php
$this->load->view('logged_in/components/footer');
?>